﻿/******************************************************************************
 *  All Rights Reserved , Copyright (C) 2012 , EricHu. 
 *  作    者： EricHu
 *  创建时间： 2012-7-20 16:35:47
 ******************************************************************************/

using System;
using System.Data;

namespace RDIFramework.BusinessEntity
{
     using RDIFramework.Utilities;

     /// <summary>
     /// CiExceptionEntity
     /// 系统异常实体
     ///
     /// 修改纪录
     ///
     ///		2012-03-02 版本：1.0 EricHu 创建主键。
     ///
     /// 版本：1.0
     ///
     /// <author>
     ///		<name>EricHu</name>
     ///		<date>2012-03-02</date>
     /// </author>
     /// </summary>
    [Serializable]
    public partial class CiExceptionEntity
    {
        private int? id = null;
        /// <summary>
        /// 主键
        /// </summary>
        public int? Id
        {
            get
            {
                return this.id;
            }
            set
            {
                this.id = value;
            }
        }

        private String eventId = string.Empty;
        /// <summary>
        /// EventID
        /// </summary>
        public String EventId
        {
            get
            {
                return this.eventId;
            }
            set
            {
                this.eventId = value;
            }
        }

        private String category = string.Empty;
        /// <summary>
        /// Category
        /// </summary>
        public String Category
        {
            get
            {
                return this.category;
            }
            set
            {
                this.category = value;
            }
        }

        private String priority = string.Empty;
        /// <summary>
        /// Priority
        /// </summary>
        public String Priority
        {
            get
            {
                return this.priority;
            }
            set
            {
                this.priority = value;
            }
        }

        private String severity = string.Empty;
        /// <summary>
        /// Severity
        /// </summary>
        public String Severity
        {
            get
            {
                return this.severity;
            }
            set
            {
                this.severity = value;
            }
        }

        private String title = string.Empty;
        /// <summary>
        /// Title
        /// </summary>
        public String Title
        {
            get
            {
                return this.title;
            }
            set
            {
                this.title = value;
            }
        }

        private DateTime? timestamp = null;
        /// <summary>
        /// Timestamp
        /// </summary>
        public DateTime? Timestamp
        {
            get
            {
                return this.timestamp;
            }
            set
            {
                this.timestamp = value;
            }
        }

        private String machineName = string.Empty;
        /// <summary>
        /// MachineName
        /// </summary>
        public String MachineName
        {
            get
            {
                return this.machineName;
            }
            set
            {
                this.machineName = value;
            }
        }

        private String appDomainName = string.Empty;
        /// <summary>
        /// AppDomainName
        /// </summary>
        public String AppDomainName
        {
            get
            {
                return this.appDomainName;
            }
            set
            {
                this.appDomainName = value;
            }
        }

        private String processId = string.Empty;
        /// <summary>
        /// ProcessID
        /// </summary>
        public String ProcessId
        {
            get
            {
                return this.processId;
            }
            set
            {
                this.processId = value;
            }
        }

        private String processName = string.Empty;
        /// <summary>
        /// ProcessName
        /// </summary>
        public String ProcessName
        {
            get
            {
                return this.processName;
            }
            set
            {
                this.processName = value;
            }
        }

        private String threadName = string.Empty;
        /// <summary>
        /// 导致错误的源
        /// </summary>
        public String ThreadName
        {
            get
            {
                return this.threadName;
            }
            set
            {
                this.threadName = value;
            }
        }

        private String win32ThreadId = string.Empty;
        /// <summary>
        /// Win32ThreadId
        /// </summary>
        public String Win32ThreadId
        {
            get
            {
                return this.win32ThreadId;
            }
            set
            {
                this.win32ThreadId = value;
            }
        }

        private String message = string.Empty;
        /// <summary>
        /// 异常消息
        /// </summary>
        public String Message
        {
            get
            {
                return this.message;
            }
            set
            {
                this.message = value;
            }
        }

        private String formattedMessage = string.Empty;
        /// <summary>
        /// 字符串表示形式
        /// </summary>
        public String FormattedMessage
        {
            get
            {
                return this.formattedMessage;
            }
            set
            {
                this.formattedMessage = value;
            }
        }

        private DateTime? createOn = DateTime.Now;
        /// <summary>
        /// 创建日期
        /// </summary>
        public DateTime? CreateOn
        {
            get
            {
                return this.createOn;
            }
            set
            {
                this.createOn = value;
            }
        }

        private String createUserId = string.Empty;
        /// <summary>
        /// 创建用户主键
        /// </summary>
        public String CreateUserId
        {
            get
            {
                return this.createUserId;
            }
            set
            {
                this.createUserId = value;
            }
        }

        private String createBy = string.Empty;
        /// <summary>
        /// 创建用户
        /// </summary>
        public String CreateBy
        {
            get
            {
                return this.createBy;
            }
            set
            {
                this.createBy = value;
            }
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        public CiExceptionEntity()
        {
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="dataRow">数据行</param>
        public CiExceptionEntity(DataRow dataRow)
        {
            this.GetFrom(dataRow);
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="dataReader">数据流</param>
        public CiExceptionEntity(IDataReader dataReader)
        {
            this.GetFrom(dataReader);
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="dataTable">数据表</param>
        public CiExceptionEntity(DataTable dataTable)
        {
            this.GetFrom(dataTable);
        }

        /// <summary>
        /// 从数据表读取
        /// </summary>
        /// <param name="dataTable">数据表</param>
        public CiExceptionEntity GetFrom(DataTable dataTable)
        {
            if ((dataTable == null) || (dataTable.Rows.Count == 0))
            {
                return null;
            }
            foreach (DataRow dataRow in dataTable.Rows)
            {
                this.GetFrom(dataRow);
                break;
            }
            return this;
        }

        /// <summary>
        /// 从数据行读取
        /// </summary>
        /// <param name="dataRow">数据行</param>
        public CiExceptionEntity GetFrom(DataRow dataRow)
        {
            this.Id = BusinessLogic.ConvertToInt(dataRow[CiExceptionTable.FieldId]);
            this.EventId = BusinessLogic.ConvertToString(dataRow[CiExceptionTable.FieldEventId]);
            this.Category = BusinessLogic.ConvertToString(dataRow[CiExceptionTable.FieldCategory]);
            this.Priority = BusinessLogic.ConvertToString(dataRow[CiExceptionTable.FieldPriority]);
            this.Severity = BusinessLogic.ConvertToString(dataRow[CiExceptionTable.FieldSeverity]);
            this.Title = BusinessLogic.ConvertToString(dataRow[CiExceptionTable.FieldTitle]);
            this.Timestamp = BusinessLogic.ConvertToDateTime(dataRow[CiExceptionTable.FieldTimestamp]);
            this.MachineName = BusinessLogic.ConvertToString(dataRow[CiExceptionTable.FieldMachineName]);
            this.AppDomainName = BusinessLogic.ConvertToString(dataRow[CiExceptionTable.FieldAppDomainName]);
            this.ProcessId = BusinessLogic.ConvertToString(dataRow[CiExceptionTable.FieldProcessId]);
            this.ProcessName = BusinessLogic.ConvertToString(dataRow[CiExceptionTable.FieldProcessName]);
            this.ThreadName = BusinessLogic.ConvertToString(dataRow[CiExceptionTable.FieldThreadName]);
            this.Win32ThreadId = BusinessLogic.ConvertToString(dataRow[CiExceptionTable.FieldWin32ThreadId]);
            this.Message = BusinessLogic.ConvertToString(dataRow[CiExceptionTable.FieldMessage]);
            this.FormattedMessage = BusinessLogic.ConvertToString(dataRow[CiExceptionTable.FieldFormattedMessage]);
            this.CreateOn = BusinessLogic.ConvertToDateTime(dataRow[CiExceptionTable.FieldCreateOn]);
            this.CreateUserId = BusinessLogic.ConvertToString(dataRow[CiExceptionTable.FieldCreateUserId]);
            this.CreateBy = BusinessLogic.ConvertToString(dataRow[CiExceptionTable.FieldCreateBy]);
            return this;
        }

        /// <summary>
        /// 从数据流读取
        /// </summary>
        /// <param name="dataReader">数据流</param>
        public CiExceptionEntity GetFrom(IDataReader dataReader)
        {
            this.Id = BusinessLogic.ConvertToInt(dataReader[CiExceptionTable.FieldId]);
            this.EventId = BusinessLogic.ConvertToString(dataReader[CiExceptionTable.FieldEventId]);
            this.Category = BusinessLogic.ConvertToString(dataReader[CiExceptionTable.FieldCategory]);
            this.Priority = BusinessLogic.ConvertToString(dataReader[CiExceptionTable.FieldPriority]);
            this.Severity = BusinessLogic.ConvertToString(dataReader[CiExceptionTable.FieldSeverity]);
            this.Title = BusinessLogic.ConvertToString(dataReader[CiExceptionTable.FieldTitle]);
            this.Timestamp = BusinessLogic.ConvertToDateTime(dataReader[CiExceptionTable.FieldTimestamp]);
            this.MachineName = BusinessLogic.ConvertToString(dataReader[CiExceptionTable.FieldMachineName]);
            this.AppDomainName = BusinessLogic.ConvertToString(dataReader[CiExceptionTable.FieldAppDomainName]);
            this.ProcessId = BusinessLogic.ConvertToString(dataReader[CiExceptionTable.FieldProcessId]);
            this.ProcessName = BusinessLogic.ConvertToString(dataReader[CiExceptionTable.FieldProcessName]);
            this.ThreadName = BusinessLogic.ConvertToString(dataReader[CiExceptionTable.FieldThreadName]);
            this.Win32ThreadId = BusinessLogic.ConvertToString(dataReader[CiExceptionTable.FieldWin32ThreadId]);
            this.Message = BusinessLogic.ConvertToString(dataReader[CiExceptionTable.FieldMessage]);
            this.FormattedMessage = BusinessLogic.ConvertToString(dataReader[CiExceptionTable.FieldFormattedMessage]);
            this.CreateOn = BusinessLogic.ConvertToDateTime(dataReader[CiExceptionTable.FieldCreateOn]);
            this.CreateUserId = BusinessLogic.ConvertToString(dataReader[CiExceptionTable.FieldCreateUserId]);
            this.CreateBy = BusinessLogic.ConvertToString(dataReader[CiExceptionTable.FieldCreateBy]);
            return this;
        }
    }
}
